import { FC, memo } from 'react'
import { getAllUserList, getParkList } from '@/api/common'
import { HsAdminBaseScrollSelect } from '@hs-admin/components'

// 用户
export const HsAdminSelectUsers: FC<any> = memo((props: any) => {
  return <HsAdminBaseScrollSelect request={getAllUserList} {...props}></HsAdminBaseScrollSelect>
})

// 园区

function SelectParkList(request: any, params: any) {
  return request(params).then((res: any) =>
    res?.items.map((item: any) => ({
      label: item.park_name,
      value: item.id
    }))
  )
}

export const HsAdminSelecPark: FC<any> = memo((props: any) => {
  const { parklist } = props
  return (
    <HsAdminBaseScrollSelect
      request={(params) => (parklist === 'true' ? SelectParkList(getParkList, params) : null)}
      keywordsKey="keyword"
      {...props}></HsAdminBaseScrollSelect>
  )
})
